package com.dream.cgomall.controller;

import com.dream.cgomall.dto.GoodListID;
import com.dream.cgomall.dto.TroGoodDTO;
import com.dream.cgomall.dto.TrolletDTO;
import com.dream.cgomall.entity.CgoGoodTrollet;
import com.dream.cgomall.service.CgoGoodTrolletService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController

@RequestMapping("Tro")
public class CgoGoodsTrolletController {
    @Autowired
    private CgoGoodTrolletService cgt;
    @RequestMapping("insert")
    public boolean insertTro(@RequestBody TrolletDTO CgoGT){
        System.out.println(CgoGT.toString());
        return cgt.insertTro(CgoGT);
    }
    @RequestMapping("selectCart/{id}")
    public List<TroGoodDTO> select(@PathVariable("id") int userid){
        System.out.println(userid);
        return cgt.TroList(userid);
    }
    @RequestMapping("ALL")
    public double All(@RequestBody GoodListID GlI){
        System.out.println(GlI);
        return cgt.All(GlI);
    }
    @RequestMapping("Delete")
    public boolean deleteGoodCart(@RequestBody GoodListID GlI){
        System.out.println(GlI);
        return cgt.deleteGoods(GlI);
    }
}
